<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            width: 200px;
            height: 200px;
            border: 4px solid red;
            position: absolute;
            right: 0;
            bottom: 0;
        }
        #but{
            position: absolute;
            top: 0;
            right: 0;
        }
    </style>
</head>
<body>
    <div>
        <h1>我是广告</h1>
        <h2></h2>
        <button id="but">关闭</button>
    </div>
</body>
</html>
<script>
    // const but = document.querySelector('#but')
    // but.onclick = function(){
    //     const ddv = document.querySelector('div')
    //     ddv.style.display = 'none'
    //     setInterval(function(){
    //         ddv.style.display = 'block'
    //     },2000)
    // }
    const but = document.querySelector('#but')
    const h2 = document.querySelector('h2')
    const div1 = document.querySelector('div')
    but.onclick = () => {
        const ddv = document.querySelector('div')
        ddv.style.display = 'none'
        setTimeout(() => {
                const h3 = document.createElement('h3')
                ddv.style.display = 'block'
                h2.innerText = '我又出来了'
                div1.appendChild(h3)
                h3.innerText = '啦啦啦啦'
            },2000)
    }

</script>